from none_bot_py_plugins.mod.system import system
from none_bot_py_plugins.net import socket_main


def recv_handle(proto_recv, user_loop: socket_main.ServerLoop):
    class_name = proto_recv.__class__.__name__
    handle_name = "%s_handle" % class_name
    return globals()[handle_name](proto_recv, user_loop)


def s2c_connect_handle(proto_recv, user_loop):
    system.s_connect(user_loop.__uuid)
    return []


def s2c_login_handle(proto_recv, user_loop):
    if proto_recv.state == 1:
        return system.s_login(proto_recv.players)
    return []


def s2c_select_player_handle(proto_recv, user_loop):
    if proto_recv.state == 1:
        return []
    return []


def s2c_create_player_handle(proto_recv, user_loop):
    return system.s_create(proto_recv.state, proto_recv.players)


def s2c_delete_player_handle(proto_recv, user_loop):
    return system.s_delete(proto_recv.state, proto_recv.players)

